import Vue from 'vue'
import App from './App.vue'

import router from './router'
import './plugins/element.js'
import './assets/fonts/iconfont.css'
import axios from 'axios'
// 树形表格
import ZkTable from 'vue-table-with-tree-grid'
// 富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
// 富文本的样式表
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme


axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
// 请求拦截器
axios.interceptors.request.use(config => {
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})

// 时间过滤器
Vue.filter('dataFormat', function (originVal) {
  const data = new Date(originVal)
  const y = data.getFullYear()
  const m = (data.getMonth() + 1 + '').padStart(2, '0')
  const d = (data.getDay() + '').padStart(2, '0')

  const hh = (data.getHours() + '').padStart(2, '0')
  const mm = (data.getMinutes() + '').padStart(2, '0')
  const ss = (data.getSeconds() + '').padStart(2, '0')

  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})

Vue.prototype.$http = axios
// 设置树形表格的组件名称
Vue.component('tree-table', ZkTable)
Vue.config.productionTip = false
// 使用富文本
Vue.use(VueQuillEditor)

new Vue({
  render: h => h(App),
  router
}).$mount('#app')
